/* Copyright (C) 2011 clueless <clueless.mmopeon@gmail.com>
 *
 * This file is part of MMO Peon.
 *
 * MMO Peon is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MMO Peon is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMO Peon.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <windows.h>
#include "hooks.h"
#include "log.h"
#include "classes/objectmap.h"
#include "logic.h"
#include "packets.h"


extern "C" int __stdcall
DllMain(HINSTANCE hinstDLL __attribute__((unused)),
        DWORD fdwReason,
        LPVOID lpvReserved __attribute__((unused)))
{
    switch(fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            LogInit();
            ObjectMapInit();
            InstallHooks();
            LogicInit();
            LogWrite(LOG_NORMAL, "DLL loading complete\n");
            break;
        case DLL_PROCESS_DETACH:
            LogWrite(LOG_NORMAL, "Preparing to unload the DLL\n");
            LogicFree();
            RemoveHooks();
            ObjectMapFree();
            LogFree();
            break;
    }
    return TRUE;
}
